﻿// Copyright (c) JosephZheng. All rights reserved. See License.txt in the project root for license

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.ServiceModel;
using System.Text;

namespace Lyra.Cache.Server.Interface
{
    [ServiceContract]
    public interface ICacheServer
    {
        [OperationContract]
        byte[] Create(string region, string schema, Dictionary<string, string> views, Dictionary<string, string> extensions);
        [OperationContract]
        byte[] Drop(string region);
        [OperationContract]
        byte[] Schema(string region);
        [OperationContract]
        byte[] Statistics();
        [OperationContract]
        byte[] Memory();


        [OperationContract]
        byte[] Add(string region, string key, string obj, TimeSpan expire);

        [OperationContract]
        byte[] Set(string region, string key, string obj, TimeSpan expire, bool addIfNotExist);
        [OperationContract]
        byte[] SetWithLock(string region, string key, string obj, TimeSpan expire, string lockSession, bool addIfNotExist);

        [OperationContract]
        byte[] Get(string region, string key);
        [OperationContract]
        byte[] GetWithLock(string region, string key, string lockSession, int lockSeconds);

        [OperationContract]
        byte[] GetWithFilter(string region, string filterExpression);
        [OperationContract]
        byte[] GetWithFilterAndLock(string region, string filterExpression, string lockSession, int lockSeconds);

        [OperationContract]
        byte[] GetWithFilterUsingView(string region, string filterExpression, string view);
        [OperationContract]
        byte[] GetWithFilterAndLockUsingView(string region, string filterExpression, string view, string lockSession, int lockSeconds);

        [OperationContract]
        byte[] GetWithFilterAndTop(string region, string filterExpression, int top, string sort);
        [OperationContract]
        byte[] GetWithFilterAndTopAndLock(string region, string filterExpression, int top, string sort, string lockSession, int lockSeconds);

        [OperationContract]
        byte[] GetWithFilterAndTopUsingView(string region, string filterExpression, string view, int top, string sort);
        [OperationContract]
        byte[] GetWithFilterAndTopAndLockUsingView(string region, string filterExpression, string view, int top, string sort, string lockSession, int lockSeconds);

        [OperationContract]
        byte[] GetWithExtension(string region, string extensionName, string extensionValue);
        [OperationContract]
        byte[] GetWithExtensionAndLock(string region, string extensionName, string extensionValue, string lockSession, int lockSeconds);

        [OperationContract]
        byte[] Count(string region);
        [OperationContract]
        byte[] Count2(string region);
        [OperationContract]
        byte[] Count2WithFilter(string region, string filterExpression);
        [OperationContract]
        byte[] Count2WithExtension(string region, string extensionName, string extensionValue);

        [OperationContract]
        byte[] Remove(string region, string key);
        [OperationContract]
        byte[] RemoveWithLock(string region, string key, string lockSession);
    }
}
